!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f<a.length;++f){if(c=g[a[f]]||e(a[f]),!c)throw"module definition dependecy not found: "+a[f];d.push(c)}b.apply(null,d)}function d(a,d,e){if("string"!=typeof a)throw"invalid module definition, module id must be defined and be a string";if(d===b)throw"invalid module definition, dependencies must be specified";if(e===b)throw"invalid module definition, definition function must be specified";c(d,function(){g[a]=e.apply(null,arguments)})}function e(b){for(var c=a,d=b.split(/[.\/]/),e=0;e<d.length;++e){if(!c[d[e]])return;c=c[d[e]]}return c}function f(c){for(var d=0;d<c.length;d++){for(var e=a,f=c[d],h=f.split(/[.\/]/),i=0;i<h.length-1;++i)e[h[i]]===b&&(e[h[i]]={}),e=e[h[i]];e[h[h.length-1]]=g[f]}}var g={};d("tinymce/pasteplugin/Utils",["tinymce/util/Tools","tinymce/html/DomParser","tinymce/html/Schema"],function(a,b,c){function d(b,c){return a.each(c,function(a){b=a.constructor==RegExp?b.replace(a,""):b.replace(a[0],a[1])}),b}function e(d){function e(a){var b=a.name,c=a;if("br"===b)return void(h+="\n");if(i[b]&&(h+=" "),j[b])return void(h+=" ");if(3==a.type&&(h+=a.value),!a.shortEnded&&(a=a.firstChild))do e(a);while(a=a.next);k[b]&&c.next&&(h+="\n","p"==b&&(h+="\n"))}var f=new c,g=new b({},f),h="",i=f.getShortEndedElements(),j=a.makeMap("script noscript style textarea video audio iframe object"," "),k=f.getBlockElements();return e(g.parse(d)),h}return{filter:d,innerText:e}}),d("tinymce/pasteplugin/Clipboard",["tinymce/Env","tinymce/util/VK","tinymce/pasteplugin/Utils"],function(a,b,c){return function(d){function e(a,b){ajaxPost("/file/copyHttpImage",{src:a},function(a){if(reIsOk(a)){var c=urlPrefix+"/"+a.Item,e=d.dom;for(var f in b){var g=b[f],h=e.get(g);e.setAttrib(h,"src",c)}}})}function f(a,b){var c,f=d.dom;if(d.settings.paste_data_images||(a=a.replace(/<img[^>]+src=\"data:image[^>]+>/g,"")),c=d.fire("BeforePastePreProcess",{content:a}),c=d.fire("PastePreProcess",c),a=c.content,!c.isDefaultPrevented()){if(d.hasEventListeners("PastePostProcess")&&!c.isDefaultPrevented()){var g=f.add(d.getBody(),"div",{style:"display:none"},a);c=d.fire("PastePostProcess",{node:g}),f.remove(g),a=c.node.innerHTML}if(!c.isDefaultPrevented()){var h=d.selection.getNode();if("PRE"==h.nodeName){if(!b)try{b=$(a).text()}catch(i){}b=b.replace(/</g,"&lt;"),b=b.replace(/>/g,"&gt;"),d.insertRawContent(b)}else if(p.copyImage){var j=UrlPrefix,k={},l=(new Date).getTime();try{for(var m=$("<div>"+a+"</div"),n=m.find("img"),o=0;o<n.length;++o){var q=n.eq(o),r=q.attr("src");if(-1==r.indexOf(j)){l++;var s="__LEANOTE_IMAGE_"+l;q.attr("id",s),k[r]?k[r].push(s):k[r]=[s]}}d.insertContent(m.html());for(var r in k){var t=k[r];e(r,t)}}catch(i){d.insertContent(a)}}else d.insertContent(a)}}}function g(a){var b=a;a=d.dom.encode(a).replace(/\r\n/g,"\n");var e,g=d.dom.getParent(d.selection.getStart(),d.dom.isBlock),h=d.settings.forced_root_block;h&&(e=d.dom.createHTML(h,d.settings.forced_root_block_attrs),e=e.substr(0,e.length-3)+">"),g&&/^(PRE|DIV)$/.test(g.nodeName)||!h?a=c.filter(a,[[/\n/g,"<br>"]]):(a=c.filter(a,[[/\n\n/g,"</p>"+e],[/^(.*<\/p>)(<p>)$/,e+"$1"],[/\n/g,"<br />"]]),-1!=a.indexOf("<p>")&&(a=e+a)),f(a,b)}function h(){var a=d.dom,b=d.getBody(),c=d.dom.getViewPort(d.getWin()),e=d.inline?b.scrollTop:c.y,f=d.inline?b.clientHeight:c.h;i(),m=a.add(d.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(e+20)+"px;width: 10px; height: "+(f-40)+"px; overflow: hidden; opacity: 0"},r),a.setStyle(m,"left","rtl"==a.getStyle(b,"direction",!0)?65535:-65535),a.bind(m,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),n=d.selection.getRng(),m.focus(),d.selection.select(m,!0)}function i(){m&&(d.dom.unbind(m),d.dom.remove(m),n&&d.selection.setRng(n)),o=!1,m=n=null}function j(){return m?m.innerHTML:r}function k(a){var b={},c=a.clipboardData||d.getDoc().dataTransfer;if(c&&c.types){b["text/plain"]=c.getData("Text");for(var e=0;e<c.types.length;e++){var f=c.types[e];b[f]=c.getData(f)}}return b}function l(){var a=LeaAce.nowIsInAce();return a?(setTimeout(function(){a[0].focus()}),!0):!1}var m,n,o,p=this,q=0,r="%MCEPASTEBIN%";d.on("keydown",function(c){if(!c.isDefaultPrevented()&&(b.metaKeyPressed(c)&&86==c.keyCode||c.shiftKey&&45==c.keyCode)){if(l())return;if(o=c.shiftKey&&86==c.keyCode,c.stopImmediatePropagation(),q=(new Date).getTime(),a.ie&&o)return c.preventDefault(),void d.fire("paste",{ieFake:!0});h()}}),d.on("paste",function(b){if(!l()){var e=k(b),n=(new Date).getTime()-q<100,s="text"==p.pasteFormat||o;n||b.preventDefault(),!a.ie||n&&!b.ieFake||(h(),d.dom.bind(m,"paste",function(a){a.stopPropagation()}),d.getDoc().execCommand("Paste",!1,null),e["text/html"]=j(),i()),setTimeout(function(){var a=j();m&&m.firstChild&&"mcepastebin"===m.firstChild.id&&(s=!0),i(),(a!=r&&n||(a=e["text/html"]||e["text/plain"]||r,a!=r))&&(s?g(e["text/plain"]||c.innerText(a)):f(a,e["text/plain"]))},0);try{}catch(b){}}}),p.pasteHtml=f,p.pasteText=g}}),d("tinymce/pasteplugin/WordFilter",["tinymce/util/Tools","tinymce/html/DomParser","tinymce/html/Schema","tinymce/html/Serializer","tinymce/html/Node","tinymce/pasteplugin/Utils"],function(a,b,c,d,e,f){function g(a){return/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(a)}function h(h){var i=h.settings;h.on("BeforePastePreProcess",function(j){function k(a){function b(a,b,g,h){var i=a._listLevel||f;i!=f&&(f>i?c&&(c=c.parent.parent):(d=c,c=null)),c&&c.name==g?c.append(a):(d=d||c,c=new e(g,1),h>1&&c.attr("start",""+h),a.wrap(c)),a.name="li",b.value="";var j=b.next;j&&3==j.type&&(j.value=j.value.replace(/^\u00a0+/,"")),i>f&&d&&d.lastChild.append(c),f=i}for(var c,d,f=1,g=a.getAll("p"),h=0;h<g.length;h++)if(a=g[h],"p"==a.name&&a.firstChild){for(var i="",j=a.firstChild;j&&!(i=j.value);)j=j.firstChild;if(/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(i)){b(a,j,"ul");continue}if(/^\s*\w+\.$/.test(i)){var k=/([0-9])\./.exec(i),l=1;k&&(l=parseInt(k[1],10)),b(a,j,"ol",l);continue}c=null}}function l(b,c){if("p"===b.name){var d=/mso-list:\w+ \w+([0-9]+)/.exec(c);d&&(b._listLevel=parseInt(d[1],10))}if(h.getParam("paste_retain_style_properties","none")){var e="";if(a.each(h.dom.parseStyle(c),function(a,b){switch(b){case"horiz-align":return void(b="text-align");case"vert-align":return void(b="vertical-align");case"font-color":case"mso-foreground":return void(b="color");case"mso-background":case"mso-highlight":b="background"}("all"==m||n&&n[b])&&(e+=b+":"+a+";")}),e)return e}return null}var m,n,o=j.content;if(m=i.paste_retain_style_properties,m&&(n=a.makeMap(m)),i.paste_enable_default_filters!==!1&&g(j.content)){j.wordContent=!0,o=f.filter(o,[/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/&nbsp;/gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(a,b){return b.length>0?b.replace(/./," ").slice(Math.floor(b.length/2)).split("").join("\xa0"):""}]]);var p=i.paste_word_valid_elements;p||(p="@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br");var q=new c({valid_elements:p}),r=new b({},q);r.addAttributeFilter("style",function(a){for(var b,c=a.length;c--;)b=a[c],b.attr("style",l(b,b.attr("style"))),"span"!=b.name||b.attributes.length||b.unwrap()});var s=r.parse(o);k(s),j.content=new d({},q).serialize(s)}})}return h.isWordContent=g,h}),d("tinymce/pasteplugin/Quirks",["tinymce/Env","tinymce/util/Tools","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Utils"],function(a,b,c,d){return function(e){function f(a){e.on("BeforePastePreProcess",function(b){b.content=a(b.content)})}function g(a){return a=d.filter(a,[/^[\s\S]*<!--StartFragment-->|<!--EndFragment-->[\s\S]*$/g,[/<span class="Apple-converted-space">\u00a0<\/span>/g,"\xa0"],/<br>$/])}function h(a){if(!c.isWordContent(a))return a;var f=[];b.each(e.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?("+f.join("|")+")[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*","g");return a=d.filter(a,[[g,"$1"]]),a=d.filter(a,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function i(a){return(e.settings.paste_remove_styles||e.settings.paste_remove_styles_if_webkit!==!1)&&(a=a.replace(/ style=\"[^\"]+\"/g,"")),a}a.webkit&&(f(i),f(g)),a.ie&&f(h)}}),d("tinymce/pasteplugin/Plugin",["tinymce/PluginManager","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks"],function(a,b,c,d){var e,f;a.add("paste",function(a){function g(){"text"==i.pasteFormat?(this.active(!1),i.pasteFormat="html"):(i.pasteFormat="text",this.active(!0),e||(a.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),e=!0))}function h(){i.copyImage?(this.active(!1),i.copyImage=!1):(i.copyImage=!0,this.active(!0),f||(a.windowManager.alert("When copy other site's images (not in leanote) into editor, it will copy the image into your album."),f=!0))}var i,j=this,k=a.settings;j.clipboard=i=new b(a),j.quirks=new d(a),j.wordFilter=new c(a),a.settings.paste_as_text&&(j.clipboard.pasteFormat="text"),k.paste_preprocess&&a.on("PastePreProcess",function(a){k.paste_preprocess.call(j,j,a)}),k.paste_postprocess&&a.on("PastePostProcess",function(a){k.paste_postprocess.call(j,j,a)}),a.addCommand("mceInsertClipboardContent",function(a,b){b.content&&j.clipboard.pasteHtml(b.content),b.text&&j.clipboard.pasteText(b.text)}),a.paste_block_drop&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),a.settings.paste_data_images||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:g,active:"text"==j.clipboard.pasteFormat}),a.addButton("pasteCopyImage",{icon:"copy",tooltip:"When Paste other site's image, copy it into my album as public image",onclick:h,active:j.clipboard.copyImage===!0}),a.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:i.pasteFormat,onclick:g})})}),f(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks","tinymce/pasteplugin/Plugin"])}(this);